namespace PProdAPI.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.employees",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Name = c.String(nullable: false),
                        HireDate = c.DateTime(nullable: false),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.productions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        createdate = c.DateTime(nullable: false),
                        date = c.DateTime(nullable: false),
                        employeeId = c.Int(nullable: false),
                        shiftId = c.Int(nullable: false),
                        machineId = c.Int(nullable: false),
                        itemId = c.Int(nullable: false),
                        amount = c.Decimal(nullable: false, precision: 18, scale: 2),
                        actualHours = c.Decimal(nullable: false, precision: 18, scale: 2),
                        scheduledHours = c.Decimal(nullable: false, precision: 18, scale: 2),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.employees", t => t.employeeId, cascadeDelete: true)
                .ForeignKey("dbo.items", t => t.itemId, cascadeDelete: true)
                .ForeignKey("dbo.machines", t => t.machineId, cascadeDelete: true)
                .ForeignKey("dbo.shifts", t => t.shiftId, cascadeDelete: true)
                .Index(t => t.employeeId)
                .Index(t => t.itemId)
                .Index(t => t.machineId)
                .Index(t => t.shiftId);
            
            CreateTable(
                "dbo.items",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ItemID = c.String(nullable: false),
                        Description = c.String(),
                        MinimumStock = c.Decimal(nullable: false, precision: 18, scale: 2),
                        MaximumStock = c.Decimal(nullable: false, precision: 18, scale: 2),
                        PalletWeight = c.Decimal(nullable: false, precision: 18, scale: 2),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.machines",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        MachineName = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.shifts",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ShiftName = c.String(nullable: false),
                        NickName = c.String(),
                        DayShift = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.productions", "shiftId", "dbo.shifts");
            DropForeignKey("dbo.productions", "machineId", "dbo.machines");
            DropForeignKey("dbo.productions", "itemId", "dbo.items");
            DropForeignKey("dbo.productions", "employeeId", "dbo.employees");
            DropIndex("dbo.productions", new[] { "shiftId" });
            DropIndex("dbo.productions", new[] { "machineId" });
            DropIndex("dbo.productions", new[] { "itemId" });
            DropIndex("dbo.productions", new[] { "employeeId" });
            DropTable("dbo.shifts");
            DropTable("dbo.machines");
            DropTable("dbo.items");
            DropTable("dbo.productions");
            DropTable("dbo.employees");
        }
    }
}
